<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>P62 【例3-8】demo08.html</title>
</head>

<body>
    <script>
        var res = [];
        var arr = ['a', 'b', 'a', 'c', 'a', 'd'];
        var search = 'a';
        var i = arr.lastIndexOf(search);
        while (i !== -1) {
            res.push(i);
            i = (i > 0 ? arr.lastIndexOf(search, i - 1) : -1);
        }
        console.log('元素' + search + '在数组中的所有位置为：' + res);
    </script>
    <a href="../首页/page03.html">
        <h2>返回上一页面</h2>
    </a>
</body>

</html>